const Schedule = require('node-schedule');
const categoryService = require('./services/category')

const schedule = {
    updateCategoryArticle(callback) {
        const rule = new Schedule.RecurrenceRule()
        // 每天执行
        rule.hour = 0;
        rule.minute = 0;
        rule.second = 0;
        // rule.second = [0,10,20,30,50];
        Schedule.scheduleJob(rule, function () {
            console.log('do schedule')
            callback().then(res => {
                // console.log(res)
                categoryService.updateArticleCountUnderCategory(res)
            })
        })
    }
}

module.exports = schedule
